package com.dsl.tms.repository;

import com.dsl.tms.entity.db.MessageTrash;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;


public interface MessageTrashRepository extends JpaRepository<MessageTrash,Integer> {

    @Query(value = "SELECT content FROM message_trash WHERE message_id = :message_id",nativeQuery = true)
    public String findContentByMessage_id(@Param("message_id") int id);

    @Query("SELECT messageTrash FROM MessageTrash messageTrash WHERE messageTrash.message_id = :message_id")
    public MessageTrash findMessageTrashByMessage_id(@Param("message_id") int message_id);

    @Modifying
    @Query(value = "DELETE FROM message_trash WHERE message_id = :message_id",nativeQuery = true)
    public void deleteByMessage_id(@Param("message_id") int message_id);


}
